package com.example.project.manageController;

import com.example.project.dao.CarDAO;
import com.example.project.dao.ParkingDAO;
import com.example.project.dao.ParkingTypeDAO;
import com.example.project.pojo.Parking;
import com.example.project.pojo.ParkingType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("manage")
public class ManageParkingUpdateController {

    @RequestMapping("parkingUpdate")
    public String parkingUpdate(Model model, Integer id)

    {
        ParkingDAO parkingDAO = new ParkingDAO();
     Parking parking= parkingDAO.findParkingByID(id);
        ParkingTypeDAO parkingTypeDAO =new ParkingTypeDAO();
       List<ParkingType> parkingTypeList= parkingTypeDAO.findAll();
        model.addAttribute("parking",parking);
        model.addAttribute("parkingTypeList",parkingTypeList);
        return "manage/parkingUpdate";
    }
    @RequestMapping("updateParking")
    public String  updateParking(Parking parking){
        ParkingDAO parkingDAO =new ParkingDAO();
        parkingDAO.updateParking(parking);
        return "redirect:parkingCheck";
    }

}
